package org.gpf.dao.impl;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

import org.gpf.dao.ArticleDetailDAO;
import org.gpf.po.ArticleDetail;
import org.gpf.util.DBUtil;

public class ArticleDetailDAOImpl implements ArticleDetailDAO{

	@Override
	public ArticleDetail queryArticleDetails(int id) throws Exception {
		
		String sql = "SELECT id,title,content,author,pdate,count FROM article_detail WHERE id = ?";
		
		ArticleDetail articleDetail = null;
		Connection conn = DBUtil.getConnection();
		PreparedStatement pstmt = conn.prepareStatement(sql);
		pstmt.setInt(1, id);
		ResultSet rs = pstmt.executeQuery();
		while (rs.next()) {
			articleDetail = new ArticleDetail();
			articleDetail.initFieldsFromResultSet(articleDetail, rs);
		}
		return articleDetail;
		
	}

}
